package test_achieve.web;

import constant.Constant;
import util.tools.CommonTools;
import cucumber.api.java.en.Given;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import util.JdbcUtil;

import java.util.List;

/**
 * Created by chenkuo on 2017/8/3.
 */
public class AverageUser {

    @Given("^w选择寄付下单$")
    public void w选择寄付下单() throws Throwable {
        CommonTools.scrollToElement(Constant.driverWeb,By.xpath("//*[@id=\"sendPay\"]"));
        Constant.driverWeb.findElement(By.xpath("//*[@id=\"sendPay\"]")).click();//选择寄付下单
        WebElement OrderAmount =CommonTools.findElement(Constant.driverWeb,"id","total_money");//订单总金额
        Constant.sendGeneralTotalIncome = Float.parseFloat(OrderAmount.getText());//寄付到付闪送员订单理论收入（未抽佣）
    }


    @Given("^获取并输入寄付短信验证码：(.+)：(.+)$")
    public void 获取并输入寄付短信验证码(String username,String sendMobile) throws Throwable {
        if (!(username.equals(sendMobile))) {
            List<Integer> Code = JdbcUtil.sqlIntList("");
            //需要解决输入图形验证码的问题
        }

    }

    @Given("^w今日订单中判断订单为寄付$")
    public void w今日订单中判断订单为寄付() throws Throwable {
        Method.qeuryAllOrderContent(Constant.OrderNumbuter.get(Constant.OrderNumbuter.size()-1),"寄付");
    }

    @Given("^w选择到付下单$")
    public void 选择到付下单() throws Throwable {
        CommonTools.scrollToElement(Constant.driverWeb,By.xpath("//*[@id=\"recvPay\"]"));
        CommonTools.waitElementLoad(Constant.driverWeb,"xpath","//*[@id=\"recvPay\"]");
        Constant.driverWeb.findElement(By.xpath("//*[@id=\"recvPay\"]")).click();//选择到付下单
        WebElement OrderAmount = Constant.driverWeb.findElement(By.id("total_money"));//订单总金额
        Constant.sendGeneralTotalIncome = Float.parseFloat(OrderAmount.getText());//寄付到付闪送员订单理论收入（未抽佣
    }

    @Given("^w取消余额支付$")
    public void w取消余额支付() throws Throwable {
        Constant.driverWeb.findElement(By.xpath("//*[@id=\"useBalance\"]")).click();//余额支付勾选框

    }

    @Given("^w今日订单中判断订单为到付$")
    public void w今日订单中判断订单为到付() throws Throwable {
        Thread.sleep(3000);
        Method.qeuryAllOrderContent(Constant.OrderNumbuter.get(Constant.OrderNumbuter.size()-1),"到付");
    }
}
